package com.penghaisoft.microwms.base.web.data.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.penghaisoft.microwms.base.web.data.service.IMdSupplierService;
import com.penghaisoft.microwms.base.web.supplier.dao.MdSupplierMapper;
import com.penghaisoft.microwms.common.data.model.MdSupplier;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;

/**
 * @Description 供应商
 * @author luoteng
 * @date 2018年7月24日 下午9:50:32 
 * @version 1.0
 */
@Service("mdSupplierService")
public class MdSupplierServiceImpl extends BaseService implements IMdSupplierService{
		@Resource
		private MdSupplierMapper mdSupplierMapper;
		
	  /**
	   * 新增记录
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp create(MdSupplier mdSupplier){
			mdSupplierMapper.create(mdSupplier);
			return success();
		}

	  /**
	   * 删除记录（逻辑删除）
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp delete(MdSupplier mdSupplier){
			mdSupplierMapper.delete(mdSupplier);
			return success();
		}
		
	  /**
	   * 查询列表
	   * @param pager
	   * @param baseResource
	   * @return
	   */
		@Override
		public Pager<MdSupplier> findListByCondition(int page, int rows,MdSupplier condition){
		    Pager<MdSupplier> pager = new Pager<>();
		    pager.setPage(page);
		    pager.setRows(rows);
    		long size = mdSupplierMapper.queryCount(condition);
    		List<MdSupplier> records = new ArrayList<MdSupplier> ();
    		if(size > 0){
    			records = mdSupplierMapper.queryList(pager,condition);
    		}
			pager.setRecords(records);
			pager.setTotalCount(size);
			return pager;
		}

	  /**
	   * 查询单条
	   * @param id
	   * @return
	   */
		@Override
		public MdSupplier findById(String id){
			return mdSupplierMapper.queryById(id);
		}
		
	  /**
	   * 修改记录
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp update(MdSupplier mdSupplier){
			mdSupplierMapper.updateBySelect(mdSupplier);
			return success();
		}
		
		@Override
		public List<MdSupplier> queryList(MdSupplier condition){
			return mdSupplierMapper.queryByAny(condition);
		}

}
